package com.lizhijun.service.impl;

import com.lizhijun.mapper.DepartmentMapper;
import com.lizhijun.pojo.Department;
import com.lizhijun.service.DepartmentService;
import com.lizhijun.utils.MybatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("departmentService")
public class DepartmentServiceImpl implements DepartmentService {

    private SqlSessionFactory sqlSessionFactory = MybatisUtil.getSqlSessionFactory();

    @Override
    public List<Department> findAllDepartment() {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        DepartmentMapper mapper = sqlSession.getMapper(DepartmentMapper.class);
        List<Department> allDepartment = mapper.findAllDepartment();
        sqlSession.close();
        return allDepartment;
    }
}
